package com.example.demoday.mapper;

import com.example.demoday.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

//@Mapper
//public interface UserMapper {
//
//    @Insert("insert into user(username, password, nickname, email, user_pic, create_time, update_time) " +
//            "values(#{username}, #{password}, #{nickname}, #{email}, #{userPic}, #{createTime}, #{updateTime})")
//    void add(User user);
//
//    @Delete("delete from user where id = #{id}")
//    void del(int id);
//
//    @Update("update user set username = #{username}, password = #{password}, nickname = #{nickname}, email = #{email}, " +
//            "user_pic = #{userPic}, update_time = #{updateTime} where id = #{id}")
//    void update(User user);
//
//    @Select("select * from user where id = #{id}")
//    User detail(int id);
//}
@Mapper
public interface UserMapper {
    void add(User user); // 添加用户
    void del(int id);    // 删除用户
    void update(User user); // 更新用户
    User detail(int id); // 获取用户详情
    List<User> findByName(@Param("name") String name); // 精确查询姓名
    List<User> findByEmail(@Param("email") String email); // 模糊查询邮箱
    List<User> findAll(@Param("offset") int offset, @Param("limit") int limit); // 分页查询
}